package module1.tests;

import java.util.*;

import org.junit.Assert;
import org.junit.Test;

import static module1.main.PalindromeSearcher.checkMinimumInputSymbols;
import static module1.main.PalindromeSearcher.inputLine;
import static module1.main.PalindromeSearcher.searchPalindromes;

public class PalindromeSearcherTest {

    @Test
    public void searchPalindromesTest() {
	// test for null
	String line = null;
	Assert.assertNull(searchPalindromes(line));

	// test for correct values
	line = "aaabbbaaa";
	Set<String> expected = new TreeSet<>();
	expected.add("aaa");
	expected.add("aaabbbaaa");
	expected.add("aabbbaa");
	expected.add("abbba");
	expected.add("bbb");
	Set<String> actual = searchPalindromes(line);
	Assert.assertEquals(expected, actual);
    }

    @Test
    public void checkMinimumInputSymbolsTest() {
	// test for null
	String line = null;
	Assert.assertFalse(checkMinimumInputSymbols(line));

	// test for the correct amount of symbols #1
	line = "aaa";
	Assert.assertFalse(checkMinimumInputSymbols(line));

	// test for the correct amount of symbols #2
	line = "";
	boolean expected = true;
	boolean actual = checkMinimumInputSymbols(line);
	Assert.assertEquals(expected, actual);
    }

    @Test
    public void inputLineTest() {
	String expected = "aa";
	String actual = inputLine();
	Assert.assertEquals(expected, actual);
    }
}
